package com.wzq.app.ui;

import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.MediaController;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.VideoView;

import com.wzq.app.R;
import com.wzq.app.api.Api;
import com.wzq.app.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ProjectName: wzq
 * @Package: com.wzq.app.ui
 * @ClassName: VideoActivity
 * @Description: java类作用描述
 * @Version: 1.0
 */
public class VideoActivity extends BaseActivity {
    private static final String TAG = "VideoActivity";
    String url = "";
    @BindView(R.id.video)
    VideoView video;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.head_left_text)
    TextView headLeftText;
    @BindView(R.id.title)
    RelativeLayout title;

    @Override
    public int getLayoutId() {
        return R.layout.video_activity;
    }

    @Override
    public void configView() {
        String fileName = getIntent().getStringExtra("fileName");
        String fname = getIntent().getStringExtra("Name");
        name.setText(fname);
        url = Api.VIDEO_URL + fileName;
        Log.d(TAG, "视频URL：" + url);
        video.setVideoURI(Uri.parse(url));
        MediaController mediaController = new MediaController(this);
        video.setMediaController(mediaController);
        video.requestFocus();
        video.start();
        headLeftText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void requestData() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
